/*
 * Tezad - Classic puzzle game
 * Copyright 2009 Shayne Riley and Paul Maseberg
 *
 * Tezad is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Tezad is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Tezad.  If not, see <http://www.gnu.org/licenses/>
 * or write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * To contact the authors on questions or issues regarding the license,
 * you may send an email to <pezads at gmail dot com>
 */

#ifndef GAMEMINOSTRUCT_H_
#define GAMEMINOSTRUCT_H_

#include "GameMinoState.h"

/**
 * Provides the structure to each Mino. A Mino is a collection of individual
 * bricks. There are seven total tetrominoes: I, J, L, O, S, T, Z (Each one is
 * composed of four bricks each. Each brick must be connected either vertically
 * or horizontally. (Mino is short for polyomino.)
 *
 * Each brick is represented as an int, although this may change later.
 *
 * Since the assignment operator is disabled for some reason, you'll need to
 * get the minos using pointer to const GameMinoStruct, like so:
 * GameMinoStruct const *activeMino = &GameMinoStruct::mino(0);
 */
class GameMinoStruct
{
public:
    /**
     * Get the structure of one of the seven tetrominoes. They are:
     * - I = 0
     * - J = 1
     * - L = 2
     * - O = 3
     * - S = 4
     * - T = 5
     * - Z = 6
     *
     * @param mino  The mino to get. Valid range is 0-6. Any other results in
     * an out-of-range exception.
     * @return The structure of a tetromino.
     */
    static const GameMinoStruct& mino(int minoNum);

    /**
     * Returns the row and column of each brick of the Mino, if it were given
     * its state (which is the orientation and position of the origin brick).
     * The two arrays must already be allocated by the caller to have at least
     * 4 elements each. The position of each brick is given with outRows and
     * outCols.
     *
     * @param inState The state of the polyomino (orientation and position).
     * @param outRows An array with 4 elements. Used with outCols, each
     *  brick is given a position. (For example, brick 0 would have a row of
     *  outRows[0] and a column of outCols[0].) This must already be allocated
     *  by the caller.
     * @param outCols An array with 4 elements. See outRows for more info. This
     * must also already be allocated by the caller.
     * @param outN  The number of bricks in the Mino.
     */
    void bricks(const GameMinoState& inState, int outRows[], int outCols[]) const;

    /**
     * Return the brick style. It is a number between 1 and 7:
     * - I = 1
     * - J = 2
     * - L = 3
     * - O = 4
     * - S = 5
     * - T = 6
     * - Z = 7
     * @return the brick style as an int.
     */
    int brickStyle() const;
private:
    /// Private ctor, because the right way to get Minos is with the mino method.
    GameMinoStruct(int bricksRows[], int bricksCols[], int inBrickStyle);
    /// Private default ctor, because the way arrays are done, this must exist.
    GameMinoStruct();
    /// Destructor for a class that will never be derived from.
    ~GameMinoStruct();
    /// No copying needed, do not allow. Copy ctor declared, not defined.
    GameMinoStruct(const GameMinoStruct& rhs);
    /// No assignment needed. Do not define this function.
    GameMinoStruct& operator=(const GameMinoStruct rhs);

    int mBricksRows[16];
    int mBricksCols[16];
    int mBrickStyle;
};

#endif /* GAMEMINOSTRUCT_H_ */
